<?php
include("../user/userlogincheck.php");
include("../include/config.inc.php");

$sql="SELECT * FROM ".tableprefix."store where member_id='$userid'";
$result=$db->query($sql);
$s=$db->fetch_array($result);
$store_name=$s["store_name"];
$todo=$_REQUEST["todo"];

if(isset($todo) && $todo=="todo")
{
	$grade_id=$_POST["grade_id"];
	$time=time();
	$ip=getIP();	
	if($grade_id=='2'){
		$amount=1000.00;
	}elseif($grade_id=='3'){
		$amount=5000.00;
	}else{
		GotoPage('store_ok.php');
		exit;
	}
	$sql="SELECT id FROM ".tableprefix."order order by id DESC limit 0,1;";
	$result=$db->query($sql);
	$s=$db->fetch_array($result);
	$orderid=$s["id"]+1000001;
	$orderNo='1'.date("ymdHis").$orderid;//业务编码+年的后2位+月+日+订单数(订单ID)[1 170515230101 1000001];
	$sql="insert into ".tableprefix."order(orderNo,userid,amount,ordername,payment,createtime,ip)values('$orderNo','$userid','$amount','入驻保证金','wechatPay','$time','$ip')";
	$db->query($sql);
	GotoPage('../pay/wxpay/index.php?orderNo='.$orderNo);
	exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>提交保证金 - 订戏会</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=9,Chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="stylesheet" type="text/css" href="../css/public.css">
<link rel="stylesheet" type="text/css" href="../css/publish.css">
</head>

<body>
<div class="head-nav">
	<div class="head-left"><a href="#1"><div class="back">返回</div></a></div>
	<div class="head-center">商家入驻</div>
	<div class="head-right"><a href="#"><div class="shuoming"></div></a></div>
</div>
<div class="remind"><p>提交保证金，提高诚信度，获取更多用户信任。</p></div>

<form action="" method="post" name="publishForm" id="publishForm">
<input name="todo" type="hidden" value="todo">
<div class="mod-form">
	<div class="form-group">
		<div class="form-item">
			<label>商家名称：</label>
			<input type="text" id="store_name" name="store_name" value="<?php echo $store_name;?>" readonly="readonly">
		</div>		
		<div class="form-item">
			<label>保证金：</label>
			<select name="grade_id">
  				<option value="1">普通商户（保证金:0元）</option>
  				<option value="2" selected>诚信商户（保证金:1000元）</option>
				<option value="3">特约商户（保证金:5000元）</option>
			</select>
		</div>
	</div>
	<div class="form-button"><input name="s" type="submit" id="s" value="提&nbsp;&nbsp;交"></div>
	<div class="form-readme"><p>我已阅读并同意<font color="#0099FF">《网演中国商家入驻协议》</font></p></div>
</div>
</form>

<footer id="bar-fixed">
	<a href="../" class="tab-item"><i class="icon-tabbar bar-home"></i>首页</a>
	<a href="../category.php" class="tab-item"><i class="icon-tabbar bar-message"></i>分类</a>
	<a href="../publish/" class="tab-item"><i class="icon-tabbar bar-publish"></i>发布</a>	
	<a href="../user/" class="tab-item active"><i class="icon-tabbar bar-user2"></i>我</a>
</footer>
</body>
</html>